#include "HUD.h"
#include <sstream>
#include <iostream>

HUD::HUD(Avatar& avatar) : _avatar(avatar)
{
	_player_info.setCharacterSize(20);
	_player_info.setPosition(10,10);
	_player_info.setColor(Color::White);
		if (!_font.loadFromFile("police.ttf"))
		std::cerr<<"Error : police not found"<<std::endl;
	else
		_player_info.setFont(_font);
}

HUD::~HUD(){}

void HUD::update_info()
{
	std::stringstream ss; // Used to convert integers and floats to strings 
	ss.str("");
	ss<<"Lives : "<<_avatar.get_nb_life()<<" Hearts : "<<_avatar.get_nb_heart()<<" Mushrooms : "<<_avatar.get_nb_gold();
	_player_info.setString(ss.str());
}

void HUD::draw(RenderWindow& window)
{
	update_info();
	View tmp=window.getView();
	window.setView(window.getDefaultView());
	window.draw(_player_info);
	window.setView(tmp);
}
